
angular.module('DevHelp')

.controller('DevHelp.DetailCtrl', ['$scope', '$stateParams', 'DevHelpNav', 
    function ($scope, $stateParams, DevHelpNav) {
        $scope.data = {
            structure: u9ImHd.getFullPath('img/structure.png', 'DevHelp'),
            tableHtml: '<im-grid grid-options="data.gridOptions" on-operate="onOperate(operate,item)" on-refresh="doRefresh()"></im-grid>',
            searchHtml: '<im-search placeholder="请输入批次、物料查找问题网拍" on-search="search(query)"></im-search>',
            defectHtml: 
            '<im-defect-card ng-repeat="item in data.badDetail" defect="item" readonly="true">' +
            '</im-defect-card>\n' +
            '<im-defect-card defect="data.badDetailInput" readonly="false" on-bad-pos="onBadPos(defect)" on-delete="onDelete(defect)">' +
            '</im-defect-card>',
            photoHtml: '<im-button-user photo="data.photo"></im-button-user>',
            numberInputHtml: '<im-number-input class="col im-record-column demo-demand" number="gridOptions.data[%d].DemandQty"></im-number-input>',
            cardHeaderHtml: 
            '<im-card-header card-title="缺陷信息">\n' +
            '    <span class="demo-qc-status">不合格</span>\n' +
            '</im-card-header>',
            masterItemHtml:
            '<div class="im-flow-container">\n' +
            '   <im-master-item class="im-flow-item" master-name="单号" master-value="{{data.singleMaster.MOCode}}">\n' +
            '   </im-master-item>\n' +
            '   <im-master-item class="im-flow-item" master-name="料号" master-value="{{data.singleMaster.ItemMasterCode}}">\n' +
            '   </im-master-item>\n' +
            '   <im-master-item class="im-flow-item" master-name="名称" master-value="{{data.singleMaster.ItemMasterName}}">\n' +
            '   </im-master-item>\n' +
            '   <im-master-item class="im-flow-item" master-name="批次" master-value="{{data.singleMaster.MOLotNumber}}">\n' +
            '   </im-master-item>\n' +
            '</div>'
        };

        init();

        function init () {
            var summary = DevHelpNav.getSummary($stateParams.navItemId, $stateParams.summaryId);
            if (!summary) {
                return;
            }
            $scope.data.title = summary.title;
            $scope.data.detail = u9ImHd.getFullPath('tpls/' + $stateParams.navItemId + '/' + $stateParams.summaryId + '.html', 'DevHelp');
        }
    }
]);